﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace _01__CamelCasing
{
    public class Kata
    {
        public static string ToCamelCase(string str)
        {
            //1、使用正则表达式
            //return Regex.Replace(str, @"[_-](\w)", m => m.Groups[1].Value.ToUpper());
            //2、使用Select语句
            //return string.Concat(str.Split('-', '_').Select((s, i) => i > 0 ? char.ToUpper(s[0]) + s.Substring(1) : s));
            //3、使用Join+Select语句
            //var words = str.Split('-', '_');
            //return words[0] + String.Join("", words.Skip(1).Select(x => Char.ToUpper(x[0]) + x.Substring(1)));
            //4、使用Linq语句
            return str.Split('_', '-').Aggregate((result, word) => {result += char.ToUpper(word[0]) + word.Substring(1);return result;});
        }
    }
}
